<template>
        <el-aside width="200px">
            <div class="leftlogo">
            </div>
            <el-menu
                    :unique-opened="true"
                    :default-active="$route.path"
                    exact
                    class="el-menu-vertical-demo" router>
                <template v-for="item in items ">
                    <NavItem  :key="item.menuPath" v-if="item.effective==1" :item="item" />
                </template>
            </el-menu>
        </el-aside>
</template>

<script>

    import NavItem from './leftNavItem'
    import {roleMenuTreeselect} from '@/api/menu.js'
    export default {
        name: "",
        components:{
            NavItem
        },
        data() {
            return {
                items:[],
            }
        },
        mounted(){
            this.getNav();
        },
        methods: {
            getNav(){
                roleMenuTreeselect().then(response=>{
                    if(response.code==0){
                        this.items=response.data;
                        sessionStorage.setItem('menu', JSON.stringify(this.items)) // 将菜单列表存到sessionStorage
                    }else if(response.code==10013){
                        this.msgError(response.msg);
                        this.$router.push({
                            path: "/login",
                        })
                    }else{
                        this.msgError(response.msg);
                    }
                }).catch(err => {
                    this.$router.push({
                        path: "/login",
                    })
                })
            }
        }
    }
</script>
